<%@ taglib prefix="app" uri="/app-tags"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>

<tiles:insertTemplate template="/tiles/layout.jsp">
	<tiles:putAttribute name="selected" value="gastos" />
	<tiles:putAttribute name="submenu">
		<ul>
			<li><a href="${pageContext.request.contextPath}/gastos/gasto.action" class="gastoadd">Registrar gasto</a></li>
			<li><a href="${pageContext.request.contextPath}/gastos/buscar.action" class="search">Buscar gasto</a></li>
			<sec:authorize access="hasRole('ROLE_ADMIN')">
			<li><a href="${pageContext.request.contextPath}/gastos/list-tipos.action" class="category">Tipos</a></li>
			</sec:authorize>
		</ul>
	</tiles:putAttribute>
	
	<tiles:putAttribute name="body">
		<app:tablefilter tableId="gastos" filter="false"/>		 
 
        <div id="rightnow"> 
			<h3 class="reallynow"> 
				<span>Resultado de la b&uacute;squeda</span> 
				<a href="${pageContext.request.contextPath}/gastos/buscar.action" class="search">Nueva b&uacute;squeda</a> 
				<br /> 
			</h3> 
		</div> 
        
        
        <div id="box">
        
			<table id="gastos" width="100%"> 
				<thead>
					<tr>
						<th width="40px">ID</th> 
						<th>Detalle</th>
						<th>Edificio</th>
						<th>Gasto tipo</th>
						<th>Monto</th>
						<th width="70px">Tipo</th> 
						<th width="80px">Acciones</th>
					</tr> 
				</thead> 
				<tbody>
					
					<c:forEach var="gasto" items="${gastos}">
						<sec:accesscontrollist hasPermission="GASTO" domainObject="${gasto.edificio}">
							<tr>
								<td><c:out value="${gasto.id}" /></td>
								<td><c:out value="${gasto.detalle}" /></td>
								<td><c:out value="${gasto.edificio.nombre}" /></td>
								<td><c:out value="${gasto.tipo.descripcion}" /></td>
								<td>$<c:out value="${gasto.monto}" /></td>
								<td><c:out value="${gasto.class.simpleName}" /></td>
								<td>
								
								<a href="${pageContext.request.contextPath}/gastos/detalle.action?gasto.id=${gasto.id}">
								<img src="${pageContext.request.contextPath}/img/icons/calculator.png" title="Ver detalle" width="16" height="16" /></a>
								
								<c:if test="${!gasto.consolidado}">
								<a href="${pageContext.request.contextPath}/gastos/gasto.action?gasto.id=${gasto.id}">
								<img src="${pageContext.request.contextPath}/img/icons/calculator_edit.png" title="Editar Gasto" width="16" height="16" /></a>
								<a href="${pageContext.request.contextPath}/gastos/delete.action?gasto.id=${gasto.id}">
								<img src="${pageContext.request.contextPath}/img/icons/calculator_delete.png" title="Borrar Gasto" width="16" height="16" /></a>
								<sec:authorize access="hasRole('ROLE_ADMIN')">
								<a href="#">
								<img src="${pageContext.request.contextPath}/img/icons/stamp.png" title="Consolidar Gasto" width="16" height="16" /></a>
								</sec:authorize>
								</c:if>
								</td>
							</tr>
						</sec:accesscontrollist>
					</c:forEach>
				</tbody>
			</table>
		</div>
	</tiles:putAttribute>
</tiles:insertTemplate>